package com.genius.progress;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.widget.TextView;
import com.iknow.R.styleable;
import com.iknow.util.Loger;
import java.util.Timer;
import java.util.TimerTask;

public class RoundProgressBar extends TextView
{
  private static final int TIMER_ID = 256;
  private boolean mBCartoom;
  private boolean mBRoundPaintsFill;
  private boolean mBShowBottom;
  private Paint mBottomPaint;
  private float mCurFloatProcess;
  private int mCurProgress;
  private long mCurTime;
  private Paint mFramePaint;
  private Handler mHandler;
  private int mMaxProgress;
  private int mPaintColor;
  private int mPaintWidth;
  private float mProcessRInterval;
  private RectF mRoundOval;
  private Paint mRoundPaints;
  private int mSaveMax;
  private int mSecondaryCurProgress;
  private Paint mSecondaryPaint;
  private int mSidePaintInterval;
  private int mStartProgress;
  private Timer mTimer;
  private int mTimerInterval;
  private MyTimerTask mTimerTask;

  public RoundProgressBar(Context paramContext)
  {
    super(paramContext);
    initParam();
  }

  public RoundProgressBar(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    initParam();
    TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.RoundProgressBar);
    this.mMaxProgress = localTypedArray.getInt(0, 100);
    this.mSaveMax = this.mMaxProgress;
    this.mBRoundPaintsFill = localTypedArray.getBoolean(1, true);
    if (!(this.mBRoundPaintsFill))
    {
      this.mRoundPaints.setStyle(Paint.Style.STROKE);
      this.mSecondaryPaint.setStyle(Paint.Style.STROKE);
      this.mBottomPaint.setStyle(Paint.Style.STROKE);
    }
    this.mSidePaintInterval = localTypedArray.getInt(5, 0);
    this.mBShowBottom = localTypedArray.getBoolean(4, true);
    this.mPaintWidth = localTypedArray.getInt(2, 10);
    if (this.mBRoundPaintsFill)
      this.mPaintWidth = 0;
    this.mRoundPaints.setStrokeWidth(this.mPaintWidth);
    this.mSecondaryPaint.setStrokeWidth(this.mPaintWidth);
    this.mBottomPaint.setStrokeWidth(this.mPaintWidth);
    this.mPaintColor = localTypedArray.getColor(3, -13312);
    this.mRoundPaints.setColor(this.mPaintColor);
    int i = 0x66000000 | 0xFFFFFF & this.mPaintColor;
    this.mSecondaryPaint.setColor(i);
    localTypedArray.recycle();
  }

  private void initParam()
  {
    this.mFramePaint = new Paint();
    this.mFramePaint.setAntiAlias(true);
    this.mFramePaint.setStyle(Paint.Style.STROKE);
    this.mFramePaint.setStrokeWidth(0F);
    this.mPaintWidth = 0;
    this.mPaintColor = -13312;
    this.mRoundPaints = new Paint();
    this.mRoundPaints.setAntiAlias(true);
    this.mRoundPaints.setStyle(Paint.Style.FILL);
    this.mRoundPaints.setStrokeWidth(this.mPaintWidth);
    this.mRoundPaints.setColor(this.mPaintColor);
    this.mSecondaryPaint = new Paint();
    this.mSecondaryPaint.setAntiAlias(true);
    this.mSecondaryPaint.setStyle(Paint.Style.FILL);
    this.mSecondaryPaint.setStrokeWidth(this.mPaintWidth);
    int i = 0x66000000 | 0xFFFFFF & this.mPaintColor;
    this.mSecondaryPaint.setColor(i);
    this.mBottomPaint = new Paint();
    this.mBottomPaint.setAntiAlias(true);
    this.mBottomPaint.setStyle(Paint.Style.FILL);
    this.mBottomPaint.setStrokeWidth(this.mPaintWidth);
    this.mBottomPaint.setColor(-7829368);
    this.mStartProgress = -90;
    this.mCurProgress = 0;
    this.mMaxProgress = 100;
    this.mSaveMax = 100;
    this.mBRoundPaintsFill = true;
    this.mBShowBottom = true;
    this.mSidePaintInterval = 0;
    this.mSecondaryCurProgress = 0;
    this.mRoundOval = new RectF(0F, 0F, 0F, 0F);
    this.mTimerInterval = 25;
    this.mCurFloatProcess = 0F;
    this.mProcessRInterval = 0F;
    this.mBCartoom = false;
    this.mHandler = new Handler(this)
    {
      public void handleMessage()
      {
        if ((paramMessage.what != 256) || (!(RoundProgressBar.access$1(this.this$0))));
        while (true)
        {
          do
          {
            do
            {
              return;
              RoundProgressBar localRoundProgressBar = this.this$0;
              RoundProgressBar.access$4(localRoundProgressBar, RoundProgressBar.access$2(localRoundProgressBar) + RoundProgressBar.access$3(this.this$0));
              this.this$0.setProgress((int)RoundProgressBar.access$2(this.this$0));
            }
            while (RoundProgressBar.access$2(this.this$0) <= RoundProgressBar.access$5(this.this$0));
            RoundProgressBar.access$6(this.this$0, false);
            RoundProgressBar.access$8(this.this$0, RoundProgressBar.access$7(this.this$0));
          }
          while (RoundProgressBar.access$9(this.this$0) == null);
          RoundProgressBar.access$9(this.this$0).cancel();
          RoundProgressBar.access$10(this.this$0, null);
        }
      }
    };
    this.mTimer = new Timer();
  }

  /**
   * @deprecated
   */
  public int getMax()
  {
    monitorenter;
    try
    {
      int i = this.mMaxProgress;
      monitorexit;
      return i;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  public int getProgress()
  {
    monitorenter;
    try
    {
      int i = this.mCurProgress;
      monitorexit;
      return i;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  public int getSecondaryProgress()
  {
    monitorenter;
    try
    {
      int i = this.mSecondaryCurProgress;
      monitorexit;
      return i;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  public void onDraw(Canvas paramCanvas)
  {
    super.onDraw(paramCanvas);
    if (this.mBShowBottom)
      paramCanvas.drawArc(this.mRoundOval, 0F, 360.0F, this.mBRoundPaintsFill, this.mBottomPaint);
    float f1 = 360.0F * this.mSecondaryCurProgress / this.mMaxProgress;
    paramCanvas.drawArc(this.mRoundOval, this.mStartProgress, f1, this.mBRoundPaintsFill, this.mSecondaryPaint);
    float f2 = 360.0F * this.mCurProgress / this.mMaxProgress;
    paramCanvas.drawArc(this.mRoundOval, this.mStartProgress, f2, this.mBRoundPaintsFill, this.mRoundPaints);
  }

  protected void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    super.onSizeChanged(paramInt1, paramInt2, paramInt3, paramInt4);
    Loger.i("", "W = " + paramInt1 + ", H = " + paramInt2);
    if (this.mSidePaintInterval != 0)
      this.mRoundOval.set(this.mPaintWidth / 2 + this.mSidePaintInterval, this.mPaintWidth / 2 + this.mSidePaintInterval, paramInt1 - this.mPaintWidth / 2 - this.mSidePaintInterval, paramInt2 - this.mPaintWidth / 2 - this.mSidePaintInterval);
    while (true)
    {
      return;
      int i = getPaddingLeft();
      int j = getPaddingRight();
      int k = getPaddingTop();
      int l = getPaddingBottom();
      this.mRoundOval.set(i + this.mPaintWidth / 2, k + this.mPaintWidth / 2, paramInt1 - j - this.mPaintWidth / 2, paramInt2 - l - this.mPaintWidth / 2);
    }
  }

  /**
   * @deprecated
   */
  // ERROR //
  public void setMax(int paramInt)
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: iload_1
    //   3: ifgt +6 -> 9
    //   6: aload_0
    //   7: monitorexit
    //   8: return
    //   9: aload_0
    //   10: iload_1
    //   11: putfield 74	com/genius/progress/RoundProgressBar:mMaxProgress	I
    //   14: aload_0
    //   15: getfield 170	com/genius/progress/RoundProgressBar:mCurProgress	I
    //   18: iload_1
    //   19: if_icmple +8 -> 27
    //   22: aload_0
    //   23: iload_1
    //   24: putfield 170	com/genius/progress/RoundProgressBar:mCurProgress	I
    //   27: aload_0
    //   28: getfield 172	com/genius/progress/RoundProgressBar:mSecondaryCurProgress	I
    //   31: iload_1
    //   32: if_icmple +8 -> 40
    //   35: aload_0
    //   36: iload_1
    //   37: putfield 172	com/genius/progress/RoundProgressBar:mSecondaryCurProgress	I
    //   40: aload_0
    //   41: aload_0
    //   42: getfield 74	com/genius/progress/RoundProgressBar:mMaxProgress	I
    //   45: putfield 76	com/genius/progress/RoundProgressBar:mSaveMax	I
    //   48: aload_0
    //   49: invokevirtual 255	com/genius/progress/RoundProgressBar:invalidate	()V
    //   52: goto -46 -> 6
    //   55: astore_2
    //   56: aload_0
    //   57: monitorexit
    //   58: aload_2
    //   59: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   9	52	55	finally
  }

  /**
   * @deprecated
   */
  public void setProgress(int paramInt)
  {
    monitorenter;
    try
    {
      this.mCurProgress = paramInt;
      if (this.mCurProgress < 0)
        this.mCurProgress = 0;
      if (this.mCurProgress > this.mMaxProgress)
        this.mCurProgress = this.mMaxProgress;
      invalidate();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  public void setSecondaryProgress(int paramInt)
  {
    monitorenter;
    try
    {
      this.mSecondaryCurProgress = paramInt;
      if (this.mSecondaryCurProgress < 0)
        this.mSecondaryCurProgress = 0;
      if (this.mSecondaryCurProgress > this.mMaxProgress)
        this.mSecondaryCurProgress = this.mMaxProgress;
      invalidate();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  /**
   * @deprecated
   */
  public void startCartoom(int paramInt)
  {
    monitorenter;
    if (paramInt > 0);
    try
    {
      boolean bool = this.mBCartoom;
      if (bool)
      {
        monitorexit;
        return;
      }
      this.mBCartoom = true;
      if (this.mTimerTask != null)
      {
        this.mTimerTask.cancel();
        this.mTimerTask = null;
      }
      setProgress(0);
      setSecondaryProgress(0);
      this.mSaveMax = this.mMaxProgress;
      this.mMaxProgress = (paramInt * 1000 / this.mTimerInterval);
      this.mProcessRInterval = (this.mTimerInterval * this.mMaxProgress / paramInt * 1000);
      this.mCurFloatProcess = 0F;
      this.mCurTime = 0L;
      this.mTimerTask = new MyTimerTask(this);
    }
    finally
    {
      monitorexit;
    }
  }

  /**
   * @deprecated
   */
  public void stopCartoom()
  {
    monitorenter;
    try
    {
      this.mBCartoom = false;
      this.mMaxProgress = this.mSaveMax;
      setProgress(0);
      if (this.mTimerTask != null)
      {
        this.mTimerTask.cancel();
        this.mTimerTask = null;
      }
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  class MyTimerTask extends TimerTask
  {
    public void run()
    {
      RoundProgressBar.access$0(this.this$0).obtainMessage(256).sendToTarget();
    }
  }
}